﻿using System;
using System.Collections.Generic;
using Color = System.Drawing.Color;
using SwinGame;

namespace Gundam_2._0_Alpha.src
{
    public class Summon: CharacterAction
    {
        public Summon(Character c, bool persistant, int row, int colEnd, int count, int lockoutLevel)
            : base(c, persistant, row, colEnd, count, lockoutLevel)
        { }

        public int Count(string name, GameController gc)
        {
            
            int tempvalue = 0;
            foreach(DestroyableObject c in gc.GameStages.Peek().CharList)
            {
                if (c.Name.Contains(name))
                    tempvalue++;
            }
            return tempvalue;
        }

        public override void DoAction(GameController gc)
        {
            int nameValue = Count("Zaku", gc);
            string name = "Summoned Zaku " + nameValue;
            Sprite gundamSprite = Sprites.CreateSprite(Resources.LoadBitmap(Resources.PathToResource("CharSprites\\zaku.png")), 5, 1, 320, 240);

            int row = 0, colEnd = 1, count = 7,
            shootOffsetX = gundamSprite.Width / 2 - 30,
            shootOffsetY = gundamSprite.Height / 2 - 40;

            SpriteUtils utils= new SpriteUtils();

            utils.ActivateAnimationRow(gundamSprite, row, colEnd, count);

            gundamSprite.X = Core.Rnd(1000);
            gundamSprite.Y = Core.Rnd(500);

            Character c = new Character(name, gundamSprite, shootOffsetX, shootOffsetY, 500, new ZakuAI());

            gc.GameStages.Peek().ToAdd.Add(c);
        }

        public override void Reset(GameController gc)
        { }
    }
}
